package com.mud.dnd.domain.model;

import java.io.Serializable;

import javax.persistence.*;

import org.codehaus.jackson.annotate.JsonIgnore;

/**
 * Entity implementation class for Entity: CardAction
 *
 */
@Entity
public class CardAction implements Serializable, Comparable<CardAction> {

	
	private static final long serialVersionUID = 1L;

	public CardAction() {
		super();
	}
	

	private int id;
	private Card card;
	private Action action;
	private int amount;
	private int cardId;
	private int actionId;
	private int actionOrder;
	
	

	public CardAction(Card card, Action action, int amount, int order) {
		super();
		this.card = card;
		this.action = action;
		this.amount = amount;
		this.actionOrder = order;
		
		actionId = action.getId();
		cardId = card.getId();
	}
	
	@Id    
	@GeneratedValue
	public int getId() {
		return id;
	}



	public void setId(int id) {
		this.id = id;
	}
	
	@JsonIgnore
	@ManyToOne
	@JoinColumn(name="card_id")
	public Card getCard() {
		return card;
	}
	public void setCard(Card card) {
		this.card = card;
		cardId = card.getId();
	}
	
	@JsonIgnore
	@ManyToOne
	@JoinColumn(name="action_id")
	public Action getAction() {
		return action;
	}
	public void setAction(Action action) {
		this.action = action;
		actionId = action.getId();
	}
	public int getAmount() {
		return amount;
	}
	public void setAmount(int amount) {
		this.amount = amount;
	}

	@Transient
	public int getCardId() {
		return cardId;
	}

	public void setCardId(int cardId) {
		this.cardId = cardId;
	}

	@Transient
	public int getActionId() {
		return actionId;
	}

	public void setActionId(int actionId) {
		this.actionId = actionId;
	}

	public int getActionOrder() {
		return actionOrder;
	}

	public void setActionOrder(int order) {
		this.actionOrder = order;
	}

	@Override
	public int compareTo(CardAction otherAction) {
		return actionOrder-otherAction.getActionOrder();
	}
	
	
	
	
	
   
}
